Skip to content

Let /gstack-ship handle very large results PRs (GST-4003) - #4847

Merged
capy-ai[bot] merged 6 commits into
mainfrom
large-results-prs-ship-scaling
Nov 26, 2026
Merged

capy-ai[bot] merged 6 commits into
mainfrom
large-results-prs-ship-scaling

Conversation

@garrytan

@garrytan garrytan commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

/gstack-ship now works on results PRs with tens of thousands of files and hundreds of megabytes of diff: more exclusion patterns, a secrets check with no size limit, a faster review plan and docs check, and bulleted ruled notes.
Why: two 16,000-file results PRs hit each of these limits in real runs.
Nothing to do: existing policies keep working unchanged.

What changed
  • More exclusion patterns. review_exclude_paths takes up to 256 patterns (was 64). A list longer than 64 must also fit its exclude pathspecs in 24,000 argument bytes together, because every reviewer's single git diff includes all of them. Every list the old cap accepted still validates. An older gstack reads a longer list as invalid and reviews every file, which is safe.
  • Better fix advice when a reviewer's diff is too big. The suggestion never offers to hide docs/ (a results report is what the reviewer needs to read) and counts only data, log and binary bytes. When the suggested folders would push the base list past the cap or the byte budget, it prints no JSON and asks for the existing patterns to be merged instead of printing a policy gstack would refuse.
  • Secrets check with no size limit. The pre-merge secrets check and gstack-banned-terms used to read the whole diff through a 256 MiB pipe. git now writes it to a private file that is read back in whole-file parts (lib/diff-parts.ts), so each parser sees exactly what it saw before. A 361.8 MB diff now reads in 4 parts in 3.9 s.
  • Faster review plan. Matching the exclusion patterns now takes one git diff plus a cheap match per pattern instead of one diff per pattern. The search for code that names excluded files hands git grep each path's extension instead of all 16,165 paths (37 s down to 0.4 s for that grep) and finds the exact paths in each file it reads. On a real 16,165-file PR the plan went from 180 s to 100 s on 4 cores, with byte-identical output.
  • Faster docs check. The docs-only check finds which files name each changed doc with one git grep -f - instead of one grep per file: 5.6 s and one grep on the same PR.
  • Bulleted ruled notes. A PR body may list each Ruled note: … line as a - or * list item. The rest of the line must still match word for word.
Not in this PR

A reviewer diff that is still over 2 MB after exclusions still stops with REVIEW_DIFF_TOO_LARGE. Splitting it into several bounded reviewer slices changes how a review pass records and checks its reviewers, so it comes in a follow-up PR.

Testing

New focused tests: test/diff-parts.test.ts, test/docs-only-batched.test.ts, test/review-exclude-match.test.ts, test/review-exclude-pattern-cap.test.ts and test/ruled-note-bullets.test.ts. They cover a file that replaces a folder of the same name, bracket and backslash patterns (a folder literally named res/[0-9]*), a consumer file git reads from the index (assume-unchanged), and 64 long multibyte patterns that the old cap accepted. The 64-pattern fallback tests now use 257 patterns. 336 tests in the review-exclude, docs-only, secrets, diff-parts, ship-policy and module-size suites pass locally, along with bun run typecheck and bun run typecheck:test. CI runs the full suite.

Documentation

Status: updated (one factual doc correction, no blockers)

Scope: the 21 selected files from fd81a04 to b8c6f60 (committed only; nothing staged, unstaged or untracked), checked against docs/ship-policy.md, docs/troubleshooting.md, docs/review-policy.md and docs/pregate.md.

Documentation health

  • docs/ship-policy.md: current. It already documents the 256-pattern and 24,000-byte limits for review_exclude_paths, the 257-pattern fallback example and Ruled note bullets.
  • docs/troubleshooting.md: updated. The POLICY_INVALID fallback example now names 256 patterns for review_exclude_paths and 64 for review_content_patterns. The suggested-fix and Ruled note bullet wording was already current.
  • docs/review-policy.md: current. Its 256 MB consumer-scan limit is unchanged by this branch.
  • docs/pregate.md: current. Its 64-per-list limit applies to pregate.json.
  • changelog.d/large-results-prs-ship-scaling.md: matches the code (not edited).

Coverage debt: no dedicated doc says that the pre-merge secrets check and gstack-banned-terms now read large diffs in parts, or that the docs-only reference search is now batched. Both are internal speed and robustness changes, and the changelog fragment covers them. No diagrams are affected.

Review notes

Below the blocking floor; recorded here and not fixed in this PR.

  • INFORMATIONAL lib/review-exclude-match.ts:48: the per-pattern fallback has no test that forces it.
  • INFORMATIONAL lib/pregate/checks/secrets.ts:200: the 256 MiB full-context cutoff has no test that forces it.
  • Low lib/diff-parts.ts:31: git's stderr keeps the 1 MiB default buffer, so very chatty warnings could fail the diff (it fails closed).
  • Low lib/docs-only.ts:180: the batched reference read can use more memory than the old grep on very large consumer files (it fails closed).
  • Low lib/ship-policy-keys.ts:59: lists of 65 to 256 patterns have no version floor, so an older gstack sets them aside and reviews every file.
  • Low lib/ship-policy-keys.ts:65: the comment's command-line budget leaves out the keep literals and forbid_paths specs.
Agent notes

Open in Capy

GST-4003, reported from harness-evals#616 and #619. The real-PR timings come from a local clone of #616 (base 26ca0095, head 98d30986) on a 4-core cloud machine.

Approvals:
No approvals recorded for branch large-results-prs-ship-scaling.
Plan: exempt: bug fix, no plan review needed

REVIEW_LOOP: passes=3 blocking_found=6 deferred=0 noted=7 fixed=7 scope=frozen ledgers_read=4 dispatches=12

{
  "schema_version": 1,
  "pr": 4847,
  "head": "957b89a95bb93481f779941b18826a852e0256a2",
  "version": "1.104.0.0",
  "base": "main",
  "gate": {
    "free": {
      "pass": 1727,
      "fail": 0,
      "skip": 4
    }
  },
  "ci_carried": [
    {
      "lane": "free",
      "run": 45859919397,
      "attempt": 1,
      "tree": "68e52fe79a02e8f485be47aff4f3e3a1e07c9df3"
    }
  ],
  "calls": 28,
  "session_kind": "unattended",
  "run": "/home/user/.capy/work/gstack/ship-4847",
  "head_tree": "68e52fe79a02e8f485be47aff4f3e3a1e07c9df3",
  "product_patch_id": "f2120a81cf96b0a857b8ffe875dc5962063efa1e",
  "gstack_version": "1.104.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 414,
    "rules": "33831f8248a814fd",
    "base": "aa503e29f4e620a2ab689172c7fb261c7b280874",
    "registry": "aa503e29f4e620a2ab689172c7fb261c7b280874",
    "gate_scan": {
      "tagged": 0,
      "head": "957b89a95bb93481f779941b18826a852e0256a2"
    },
    "reasons": [
      "gate-class",
      "risk:money",
      "risk:secret",
      "risk:security",
      "runtime=414"
    ],
    "risk": [
      "money",
      "secret",
      "security"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @68e52fe79a02 (8 checks, current for 957b89a95bb9)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/45859919397/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/45859919575/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=68e52fe79a02 tests=38514 skipped=88 runs=45859919397/1 profiles=ci-reuse/free-tests heads=957b89a95bb9 base_moved=aa503e29f4e6 verified=2026-11-26T16:41:02.675Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "docs/, README.md and CONTRIBUTING.md against the 21 files changed from fd81a04 to b8c6f60"
  },
  "review_loop": {
    "passes": 3,
    "blocking_found": 6,
    "deferred": 0,
    "noted": 7,
    "fixed": 7,
    "scope": "frozen",
    "rounds": 3,
    "ledgers_read": 4,
    "dispatches": {
      "specialist": 9,
      "red-team": 3
    }
  },
  "gate_dispositions": [],
  "review_targeted": {
    "classes": [
      "money",
      "secret"
    ],
    "rules": "e01517eddd4b2350",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "f2120a81cf96b0a857b8ffe875dc5962063efa1e",
    "status": "done",
    "findings": 0,
    "raised_by": "targeted"
  }
}
{"head":"87f3dd7b552b7ba6eb5b19cb3f62c4c87255f96d","run":"ship-4847","status":"started","review_loop":{"passes":1,"blocking_found":1,"deferred":0,"noted":0,"fixed":1,"scope":"frozen","rounds":1,"dispatches":{"specialist":3,"red-team":1}}}

Raise the review_exclude_paths cap to 256 patterns within a 24,000-byte pathspec budget; keep docs/ and over-cap policies out of the too-large fix; read the secrets and banned-terms diffs through a file in whole-file parts; batch the docs-only reference grep; match exclusion patterns and named-by-code paths with a fixed number of git calls; accept bulleted Ruled note lines (GST-4003).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 5 commits November 26, 2026 15:18
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Keep a file that replaces a directory of the same name matched: give the head side and the deleted side of the diff their own scratch index, and fall back to one diff per pattern when an index does not list every path.

Review-Finding: p1/red-team#1 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Match bracket and backslash exclude patterns with their own git diff, read index bytes for files git grep reads from the index, bound the full-context postimages the secrets scan holds, read consumer blobs in size-bounded batches, and apply the exclude byte cap only to lists over the old 64.

Review-Finding: p2/adversarial-native#1 reader=adversarial-native
Review-Finding: p2/outside-voice#1 reader=outside-voice
Review-Finding: p2/outside-voice#2 reader=outside-voice
Review-Finding: p2/outside-voice#3 reader=outside-voice
Review-Finding: p2/outside-voice#4 reader=outside-voice
Review-Finding: p2/specialist-batched#2 reader=specialist-batched
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit 77da8a0 into main Nov 26, 2026
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant